import CreateEvent from "./createEvent"
export default class VNode {
    constructor({ tagName, props, children, attr, mode }, watcher, data) {
        this.tagName = tagName || 'span'
        this.props = props || {}
        this.children = children || []
        this.attr = attr || {}
        this.watcher = watcher
        this.el = null
        this.data = data
        this.watcher = watcher
        this.mode = mode || ''
        //广域优先 生成所有Vnode
        this.render()
        this.children.map((item, index) => {
            this.children[index] = new VNode(item, this.watcher, data)
            this.el.event.event.appendChild(this.children[index].el.event.event)
        })
    }
    render() {
        this.el = new CreateEvent(this.tagName, this.props, this.attr, this.data, this.mode, this.watcher)
    }

}